package com.ruoyi.warning.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.xuehua.SnowflakeIdUtils;
import com.ruoyi.warning.domain.EarlyWarningSetting;
import com.ruoyi.warning.mapper.EarlyWarningSettingMapper;
import com.ruoyi.warning.service.IEarlyWarningSettingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 预警设置Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-11-24
 */
@Service
public class EarlyWarningSettingServiceImpl extends ServiceImpl<EarlyWarningSettingMapper, EarlyWarningSetting> implements IEarlyWarningSettingService //修改
{
    @Autowired
    private EarlyWarningSettingMapper earlyWarningSettingMapper;

    /**
     * 查询预警设置
     * 
     * @param earlyWarningId 预警设置主键
     * @return 预警设置
     */
    @Override
    public EarlyWarningSetting selectEarlyWarningSettingByEarlyWarningId(String earlyWarningId)
    {
        return earlyWarningSettingMapper.selectEarlyWarningSettingByEarlyWarningId(earlyWarningId);
    }

    /**
     * 查询预警设置列表
     * 
     * @param earlyWarningSetting 预警设置
     * @return 预警设置
     */
    @Override
    public List<EarlyWarningSetting> selectEarlyWarningSettingList(EarlyWarningSetting earlyWarningSetting)
    {
        return earlyWarningSettingMapper.selectEarlyWarningSettingList(earlyWarningSetting);
    }

    /**
     * 新增预警设置
     * 
     * @param earlyWarningSetting 预警设置
     * @return 结果
     */
    @Override
    public int insertEarlyWarningSetting(EarlyWarningSetting earlyWarningSetting)
    {
        earlyWarningSetting.setEarlyWarningId(String.valueOf(new SnowflakeIdUtils(5,8).nextId()));
        earlyWarningSetting.setCreateTime(DateUtils.getNowDate());
        return earlyWarningSettingMapper.insertEarlyWarningSetting(earlyWarningSetting);
    }

    /**
     * 修改预警设置
     * 
     * @param earlyWarningSetting 预警设置
     * @return 结果
     */
    @Override
    public int updateEarlyWarningSetting(EarlyWarningSetting earlyWarningSetting)
    {
        earlyWarningSetting.setUpdateTime(DateUtils.getNowDate());
        return earlyWarningSettingMapper.updateEarlyWarningSetting(earlyWarningSetting);
    }

    /**
     * 批量删除预警设置
     * 
     * @param earlyWarningIds 需要删除的预警设置主键
     * @return 结果
     */
    @Override
    public int deleteEarlyWarningSettingByEarlyWarningIds(String[] earlyWarningIds)
    {
        return earlyWarningSettingMapper.deleteEarlyWarningSettingByEarlyWarningIds(earlyWarningIds);
    }

    /**
     * 删除预警设置信息
     * 
     * @param earlyWarningId 预警设置主键
     * @return 结果
     */
    @Override
    public int deleteEarlyWarningSettingByEarlyWarningId(String earlyWarningId)
    {
        return earlyWarningSettingMapper.deleteEarlyWarningSettingByEarlyWarningId(earlyWarningId);
    }
}
